﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfAGVSystem.Model
{
    public class AGVProcess
    {
        public DateTime StartTime { get; set; } = DateTime.Now;

        private bool isNewProcess;
        /// <summary>
        /// 只一次有效
        /// </summary>
        public bool IsNewProcess
        {
            get
            {
                var temval = isNewProcess;
                isNewProcess = false;
                return temval;
            }
            set { isNewProcess = value; }
        }
        private Action process;
        public string ProcessName { get; set; }

        public Action Process
        {
            get
            {
                return process;
            }
            set
            {
                if (process != value)
                {
                    IsNewProcess = true;
                    ProcessName = value.Method.Name;
                }
                process = value;
            }
        }

        public bool IsTimeOut(double minutes)
        {
            double span = (DateTime.Now - StartTime).TotalMinutes;
            return span > minutes;
        }
    }
}
